﻿using System.Collections;

namespace CustomCollections;

public class CustomersList : IEnumerable
{
    private List<Customer> customers = new List<Customer>()
    {
        new Customer()
            { Id = "A101", Name = "Bob", Email = "bob@gmail.com", CustomerType = TypeOfCustomer.VIPCustomer },
        new Customer()
            { Id = "A102", Name = "Jerry", Email = "jerry@gmail.com", CustomerType = TypeOfCustomer.VIPCustomer },
        new Customer()
            { Id = "A103", Name = "Tom", Email = "Tom@gmail.com", CustomerType = TypeOfCustomer.RegularCustomer },
    };

    public IEnumerator GetEnumerator()
    {
        for (int i = 0; i < customers.Count; i++)
        {
            yield return customers[i];
        }
    }

    public void Add(Customer cust)
    {
        if (cust.Id.StartsWith("A") || cust.Id.StartsWith("a"))
        {
            customers.Add(cust);
        }
        else
        {
            Console.WriteLine("Invalid Customer ID");
        }
        
    }
}